package com.design;

import com.design.factory.DataFactory;
import com.design.factory.MySqlDataFactory;
import com.design.factory.OracleDataFactory;
import com.design.product.connection.IConnection;
import com.design.product.dao.UserDao;

/**
 * 测试类
 */
public class MainTest {

    public static void build(DataFactory dataFactory){
        IConnection connection = dataFactory.createConnection();
        UserDao userDao = dataFactory.createUserDao();
        connection.connect();
        userDao.addUser();
        userDao.deleteUser();
        connection.close();
    }

    public static void main(String[] args) {
        System.out.println("---------------使用mysql链接数据库---------------");
        DataFactory dataFactory = new MySqlDataFactory();
        build(dataFactory);
        System.out.println("------------------------------------------------");
        System.out.println("---------------使用oracle链接数据库---------------");
        DataFactory oracleDataFactory = new OracleDataFactory();
        build(oracleDataFactory);
        System.out.println("------------------------------------------------");
    }
}
